import Cookies from 'js-cookie'

const TokenKey = 'XAUT-Token'
const TokenName = 'XAUT-Token-Name'

// "tokenName": "satoken",
// "tokenValue": "91672680-8221-4659-96ad-e28a37addc3d",
// "isLogin": true,
// "loginId": "105116",
// "loginType": "login",
// "tokenTimeout": 2591999,
// "sessionTimeout": 2591999,
// "tokenSessionTimeout": -2,
// "tokenActiveTimeout": -1,
// "loginDevice": "default-device",
// "tag": null

export function getTokenValue() {
    return Cookies.get(TokenKey)
}

export function setTokenValue(token) {
    return Cookies.set(TokenKey, token)
}

export function removeTokenValue() {
    return Cookies.remove(TokenKey)
}
export function getTokenName() {
    return Cookies.get(TokenName)
}

export function setTokenName(token) {
    return Cookies.set(TokenName, token)
}

export function removeTokenName() {
    return Cookies.remove(TokenName)
}


export function setToken(xx) {

    const { tokenName, tokenValue } = xx
    console.log(tokenName, tokenValue)
    setTokenName(tokenName)
    setTokenValue(tokenValue)
}
export function getToken() {
    return {
        tokenValue: getTokenValue(),
        tokenName: getTokenName()
    }
}
export function removeToken() {
    removeTokenName()
    removeTokenValue()
}
